home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Mr. Do outdone fade.c < prev    next >
Text File  |  1994-04-19  |  3KB  |  159 lines

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do outdone fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define    BoxSize    2
  28. #define CorrectTime 3
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30. #define theWindowWidth (boundsRect.right-boundsRect.left)
  31.  
  32. pascal short MrDoOutdoneFade(Rect boundsRect, Pattern *thePattern);
  33.  
  34. /* 25 regions on screen, in a 5 x 5 grid.  Regions alternate as to whether they
  35.    scroll up or down. */
  36.    
  37. pascal short MrDoOutdoneFade(Rect boundsRect, Pattern *thePattern)
  38. {
  39.     int            x, y;
  40.     int            vgap,hgap;
  41.     Rect        dest;
  42.     Rect        bounds[25];
  43.     
  44.     vgap=theWindowHeight/5;
  45.     hgap=theWindowWidth/5;
  46.     
  47.     for (x=0; x<25; x++)
  48.     {
  49.         switch (x)
  50.         {
  51.             case 0:
  52.             case 1:
  53.             case 2:
  54.             case 3:
  55.             case 4:
  56.                 bounds[x].top=0;
  57.                 break;
  58.             case 15:
  59.             case 16:
  60.             case 17:
  61.             case 18:
  62.             case 5:
  63.                 bounds[x].top=vgap;
  64.                 break;
  65.             case 14:
  66.             case 23:
  67.             case 24:
  68.             case 19:
  69.             case 6:
  70.                 bounds[x].top=vgap*2;
  71.                 break;
  72.             case 13:
  73.             case 22:
  74.             case 21:
  75.             case 20:
  76.             case 7:
  77.                 bounds[x].top=vgap*3;
  78.                 break;
  79.             case 12:
  80.             case 11:
  81.             case 10:
  82.             case 9:
  83.             case 8:
  84.                 bounds[x].top=vgap*4;
  85.                 break;
  86.         }
  87.         switch (x)
  88.         {
  89.             case 0:
  90.             case 15:
  91.             case 14:
  92.             case 13:
  93.             case 12:
  94.                 bounds[x].left=0;
  95.                 break;
  96.             case 1:
  97.             case 16:
  98.             case 23:
  99.             case 22:
  100.             case 11:
  101.                 bounds[x].left=hgap;
  102.                 break;
  103.             case 2:
  104.             case 17:
  105.             case 24:
  106.             case 21:
  107.             case 10:
  108.                 bounds[x].left=hgap*2;
  109.                 break;
  110.             case 3:
  111.             case 18:
  112.             case 19:
  113.             case 20:
  114.             case 9:
  115.                 bounds[x].left=hgap*3;
  116.                 break;
  117.             case 4:
  118.             case 5:
  119.             case 6:
  120.             case 7:
  121.             case 8:
  122.                 bounds[x].left=hgap*4;
  123.                 break;
  124.         }
  125.         bounds[x].bottom=bounds[x].top+vgap;
  126.         bounds[x].right=bounds[x].left+hgap;
  127.         OffsetRect(&(bounds[x]), boundsRect.left, boundsRect.top);
  128.     }
  129.     
  130.     for (x=BoxSize; x<=vgap; x+=BoxSize)
  131.     {        
  132.         StartTiming();
  133.         for (y=0; y<25; y++)
  134.         {
  135.             if (y%2)   /* these scroll up */
  136.             {
  137.                 dest=bounds[y];
  138.                 dest.top=dest.bottom-BoxSize;
  139.                 
  140.                 ScrollTheRect(&bounds[y], 0, -BoxSize, 0L);
  141.                 FillRect(&dest, *thePattern);
  142.             }
  143.             else    /* these scroll down */
  144.             {
  145.                 dest=bounds[y];
  146.                 dest.bottom=dest.top+BoxSize;
  147.                 
  148.                 ScrollTheRect(&bounds[y], 0, BoxSize, 0L);
  149.                 FillRect(&dest, *thePattern);
  150.             }
  151.         }
  152.         TimeCorrection(CorrectTime);
  153.     }
  154.     
  155.     FillRect(&boundsRect, *thePattern);        /* in case we missed any */
  156.     
  157.     return 0;
  158. }
  159.